﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.ModFlow.Domain.DomainLayer
{
    [Serializable]
   public class SpecifiedHead:MFPointSC,ICloneable
    {

            public SpecifiedHead(int i, int j, int k, int nrows, int ncolumns, int nlayers,int nPeriods)
            : base(i, j, k,nrows,ncolumns,nlayers,nPeriods)
        {
            this._sHead = new List<double>();


            this._eHead = new List<double>();


           

            for (int m = 0; m < nPeriods; m++)
            {
                this._sHead.Add(0);
                this._eHead.Add(0);
               

            }

        }

            public SpecifiedHead(int index, int nrows, int ncolumns, int nlayers, int nPeriods)
            : base(index, nrows, ncolumns, nlayers,nPeriods)
        {


            this._sHead = new List<double>();


            this._eHead = new List<double>();




            for (int m = 0; m < nPeriods; m++)
            {
                this._sHead.Add(0);
                this._eHead.Add(0);


            }

 
        }


            List<double> _sHead;

            public List<double> SHead
            {
                get { return _sHead; }

            }

            public double FirstSHead
            {
                get
                {

                    return this._sHead[0];


                }

                set
                {
                    this._sHead[0] = value;


                }

            }



            List<double> _eHead;

            public List<double> EHead
            {
                get { return _eHead; }

            }

            public double FirstEHead
            {
                get
                {

                    return this._eHead[0];


                }

                set
                {
                    this._eHead[0] = value;


                }

            }




            public object Clone()
            {
                SpecifiedHead sphead = (SpecifiedHead)this.MemberwiseClone();

                sphead._sHead = new List<double>();
                sphead._eHead = new List<double>();




                sphead.SHead.AddRange(this.SHead);

                sphead.EHead.AddRange(this.EHead);

             

                return sphead;
            }

            public override void OnResetSperiods(int nPeriods)
            {
                base.OnResetSperiods(nPeriods);

                if (this.NPeriods == nPeriods)
                {
                    return;
                }

                if (this.NPeriods < nPeriods)
                {
                    int nSub = nPeriods - this.NPeriods;
                    for (int i = 0; i < nSub; i++)
                    {
                        this.EHead.Add(this.EHead[0]);
                        this.SHead.Add(this.SHead[0]);  
                    }
                }

                else
                {
                    int nSub = this.NPeriods - nPeriods;
                    this.EHead.RemoveRange(nPeriods, nSub);
                    this.SHead.RemoveRange(nPeriods, nSub); 
                }
                this.NPeriods = nPeriods;
            }
      
    }
}
